package com.seed.application.context;

import com.seed.core.action.Action;
import com.seed.core.pojo.seed.Seed;
import com.seed.core.query.Micro;

import java.util.HashMap;
import java.util.Map;

public class Custom {
    private static Micro micro; // 自定义的主应用服务
    private static final Map<String, Micro> micros = new HashMap<>(); // 自定义的微服务

    public static void setMicro(Micro micro) {
        Custom.micro = micro;
    }

    public static void putMicro(String key, Micro micro) {
        micros.put(key, micro);
    }

    public static Map<String, Seed> getSeeds() {
        return micro == null ? null : micro.getSeeds();
    }

    public static Map<String, Action> getActions() {
        return micro == null ? null : micro.getActions();
    }

    public static Map<String, Seed> getSeeds(String microName) {
        Micro micro = micros.get(microName);
        return micro == null ? null : micro.getSeeds();
    }

    public static Map<String, Action> getActions(String microName) {
        Micro micro = micros.get(microName);
        return micro == null ? null : micro.getActions();
    }
}
